package com.example.tests;


import java.util.Random;
import java.util.Set;

import org.testng.annotations.Test;
import org.testng.Assert;
import com.example.data.GroupData;

public class GroupModificationTests extends TestBase {
	@Test
	public void groupModifyTest() throws Exception {

		int stringLength = 5;
		Set<GroupData> oldList = manager.getGroupHelper().getGroupsList();
		if (oldList.size() > 0) {
			Random rnd = new Random();
			//the number of group we want to edit - random integer from [1, current number of groups at page]
			int numberOfGroup = rnd.nextInt(oldList.size());
			System.out.println("current rnd = " + numberOfGroup);
			GroupData newGroup = new GroupData().setName(generateAlphaNumbericRandom(stringLength)).setHeader("hoho").setFooter("hoho");
			GroupData groupToModify = manager.getGroupHelper().modifyGroup(numberOfGroup, newGroup );
			Set<GroupData> newList = manager.getGroupHelper().getGroupsList();
			//compare lists
			verifyGroupChanged(oldList, groupToModify, newGroup, newList);
		} else {
			Assert.fail("List of groups is empty. At least 1 group required");
		}
	}

}
